Decisions and Loops

Control structures

The flow of control

Branching statement
Example (Step 1)

Branching statement
Example (Step 2)

Branching statement
Example (Step 3)

Branching statement
Example (Step 4)

if … else

if … else
Variations

if … else
An example

Nesting control statement
Example (Step 1)

Nesting control statement
Example (Step 2)

Nesting control statement
Example (Step 3)

Nesting control statement
Example (Step 4)

if … else
Pascal C/C++

switch

Switch
Example

switch
Importance of break

switch
Importance of break

switch
Pascal C/C++

switch (Cont.)
Pascal C/C++

Loop (while)
Example (Step 1)

Loop (while)
Example (Step 2)

Loop (while)
Example (Step 3)

Loop (while)
Example (Step 4)

while

do … while

while and do …. while
Pascal C/C++

Loop (for)
Example (Step 1)

Loop (for)
Example (Step 2)

Loop (for)
Example (Step 3)

Loop (for)
Example (Step 4)

for

for
Pascal C/C++

break, continue

break
Pascal C/C++

break (Cont.)
Pascal C/C++

return
Pascal C/C++

return (Cont.)
Pascal C/C++

The goto statement

goto
Pascal C/C++

Debugging and breakpoints

Control structures
Things to remember